package com.example.abilitydemo;

import com.example.abilitydemo.slice.FooAbilitySlice;
import com.example.abilitydemo.slice.MainAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.bundle.AbilityInfo;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class MainAbility extends Ability {
    public static final HiLogLabel loglabel = new HiLogLabel(HiLog.LOG_APP, 0x11100, "MainAbility");

    @Override
    protected void onInitialized(AbilityInfo abilityInfo) {
        //startLocalServiceAbility();
        super.onInitialized(abilityInfo);
    }

    @Override
    public void onStart(Intent intent) {
        HiLog.info(loglabel, "MainAbility onStart start ....");
        super.onStart(intent);
        super.setMainRoute(MainAbilitySlice.class.getName());
    }

    /**
     * 启动本地服务 Ability
     */
    public void startLocalServiceAbility() {
        Intent intent = new Intent();
        //构建操作方式
        Operation operation = new Intent.OperationBuilder()
                // 设备 id本地设备
                .withDeviceId("")
                // 应用的包名
                .withBundleName("com.example.abilitydemo")
                // 跳转目标的路径名 通常是包名+类名
                .withAbilityName("com.example.abilitydemo.ServiceAbility")
                .build();
        //设置操作
        intent.setOperation(operation);
        startAbility(intent);
    }
}
